package cn.edu.sdjzu.xg.eagle.bysj.controller;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import cn.edu.sdjzu.xg.eagle.bysj.annotation.IgnoreAuth;
import cn.edu.sdjzu.xg.eagle.bysj.annotation.SysLog;
import cn.edu.sdjzu.xg.eagle.bysj.entity.HuiyishishebeiEntity;
import cn.edu.sdjzu.xg.eagle.bysj.entity.view.HuiyishishebeiView;
import cn.edu.sdjzu.xg.eagle.bysj.service.Interface.HuiyishishebeiService;
import cn.edu.sdjzu.xg.eagle.bysj.utils.MPUtil;
import cn.edu.sdjzu.xg.eagle.bysj.utils.PageUtils;
import cn.edu.sdjzu.xg.eagle.bysj.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.Map;

/**
 * 会议室设备
 * 后端接口
 * @author 
 * @email 
 * @date 2025-06-02 13:29:28
 */
@RestController
@RequestMapping("/huiyishishebei")
public class HuiyishishebeiController {
    @Autowired
    private HuiyishishebeiService huiyishishebeiService;









    /**
     * 后台列表
     */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params,HuiyishishebeiEntity huiyishishebei,
                                                                                                                            HttpServletRequest request){
                                    EntityWrapper<HuiyishishebeiEntity> ew = new EntityWrapper<HuiyishishebeiEntity>();
                                                                                                                                                                                        
        
        
        PageUtils page = huiyishishebeiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huiyishishebei), params), params));
        return R.ok().put("data", page);
    }







    /**
     * 前端列表
     */
	@IgnoreAuth
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params,HuiyishishebeiEntity huiyishishebei,
		HttpServletRequest request){
        EntityWrapper<HuiyishishebeiEntity> ew = new EntityWrapper<HuiyishishebeiEntity>();

		PageUtils page = huiyishishebeiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huiyishishebei), params), params));
        return R.ok().put("data", page);
    }

	/**
     * 列表
     */
    @RequestMapping("/lists")
    public R list( HuiyishishebeiEntity huiyishishebei){
       	EntityWrapper<HuiyishishebeiEntity> ew = new EntityWrapper<HuiyishishebeiEntity>();
      	ew.allEq(MPUtil.allEQMapPre( huiyishishebei, MPUtil.camelToSnake("huiyishishebei")));
        return R.ok().put("data", huiyishishebeiService.selectListView(ew));
    }

	 /**
     * 查询
     */
    @RequestMapping("/query")
    public R query(HuiyishishebeiEntity huiyishishebei){
        EntityWrapper< HuiyishishebeiEntity> ew = new EntityWrapper< HuiyishishebeiEntity>();
 		ew.allEq(MPUtil.allEQMapPre( huiyishishebei, MPUtil.camelToSnake("huiyishishebei")));
		HuiyishishebeiView huiyishishebeiView =  huiyishishebeiService.selectView(ew);
		return R.ok("查询会议室设备成功").put("data", huiyishishebeiView);
    }
	
    /**
     * 后端详情
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
        HuiyishishebeiEntity huiyishishebei = huiyishishebeiService.selectById(id);
		huiyishishebei = huiyishishebeiService.selectView(new EntityWrapper<HuiyishishebeiEntity>().eq("id", id));
        return R.ok().put("data", huiyishishebei);
    }

    /**
     * 前端详情
     */
	@IgnoreAuth
    @RequestMapping("/detail/{id}")
    public R detail(@PathVariable("id") Long id){
        HuiyishishebeiEntity huiyishishebei = huiyishishebeiService.selectById(id);
		huiyishishebei = huiyishishebeiService.selectView(new EntityWrapper<HuiyishishebeiEntity>().eq("id", id));
        return R.ok().put("data", huiyishishebei);
    }
    



    /**
     * 后端保存
     */
    @RequestMapping("/save")
    @SysLog("新增会议室设备")
    public R save(@RequestBody HuiyishishebeiEntity huiyishishebei, HttpServletRequest request){
    	//ValidatorUtils.validateEntity(huiyishishebei);
        huiyishishebeiService.insert(huiyishishebei);
        return R.ok();
    }
    
    /**
     * 前端保存
     */
    @SysLog("新增会议室设备")
    @RequestMapping("/add")
    public R add(@RequestBody HuiyishishebeiEntity huiyishishebei, HttpServletRequest request){
    	//ValidatorUtils.validateEntity(huiyishishebei);
        huiyishishebeiService.insert(huiyishishebei);
        return R.ok();
    }



    /**
     * 修改
     */
    @RequestMapping("/update")
    @Transactional
    @SysLog("修改会议室设备")
    public R update(@RequestBody HuiyishishebeiEntity huiyishishebei, HttpServletRequest request){
        //ValidatorUtils.validateEntity(huiyishishebei);
        huiyishishebeiService.updateById(huiyishishebei);//全部更新
        return R.ok();
    }



    

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @SysLog("删除会议室设备")
    public R delete(@RequestBody Long[] ids){
        huiyishishebeiService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }

    	









}
